﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace MySQLLib
{
    public class Data
    {

        public Data(Connection connection)
        {
            this.setConnection(connection.GetConnection());
            this.loadFromDatabase();
        }

        #region Variables
//----------------------------------------------------------------------
        private Char_items _char_items;
        private Character _characters;
        private Character_jobs _character_jobs;
        private Character_quests _character_quests;
        private Character_rev _character_rev;
        private Character_tickets _character_tickets;
        private Friends _friends;
        private Friends_groups _friends_groups;
        private Guild _guild;
        private Guild_members _guild_members;
        private Guild_storage _guild_storage;
        private Guild_unions _guild_unions;
        private Guild_war _guild_war;
        private Mastery _mastery;
        private Message _message;
        private Pets _pets;
        private Pets_storage _pets_storage;
        private Rank_honor _rank_honor;
        private Rank_job_activity _rank_job_activity;
        private Rank_job_donate _rank_job_donate;
        private Saved_skills _saved_skills;
        private Storage_items _storage_items;
        private User _users;
        private MySqlConnection _conn;
//----------------------------------------------------------------------
        #endregion
        #region Properties
//----------------------------------------------------------------------
        public Char_items Char_items
        {
            get { return this._char_items; }
            set { this._char_items = value; }
        }

        public Character Character
        {
            get { return this._characters; }
            set { this._characters = value; }
        }

        public Character_jobs Character_jobs
        {
            get { return this._character_jobs; }
            set { this._character_jobs = value; }
        }

        public Character_quests Character_quests
        {
            get { return this._character_quests; }
            set { this._character_quests = value; }
        }

        public Character_rev Character_rev
        {
            get { return this._character_rev; }
            set { this._character_rev = value; }
        }

        public Character_tickets Character_tickets
        {
            get { return this._character_tickets; }
            set { this._character_tickets = value; }
        }

        public MySqlConnection Connection
        {
            get { return this._conn; }
            set { this._conn = value; }
        }

        public Friends Friends
        {
            get { return this._friends; }
            set { this._friends = value; }
        }

        public Friends_groups Friends_groups
        {
            get { return this._friends_groups; }
            set { this._friends_groups = value; }
        }

        public Guild Guild
        {
            get { return this._guild; }
            set { this._guild = value; }
        }

        public Guild_members Guild_Members
        {
            get { return this._guild_members; }
            set { this._guild_members = value; }
        }

        public Guild_storage Guild_Storage
        {
            get { return this._guild_storage; }
            set { this._guild_storage = value; }
        }

        public Guild_unions Guild_Unions
        {
            get { return this._guild_unions; }
            set { this._guild_unions = value; }
        }

        public Guild_war Guild_War
        {
            get { return this._guild_war; }
            set { this._guild_war = value; }
        }

        public Mastery Masterys
        {
            get { return this._mastery; }
            set { this._mastery = value; }
        }

        public Message Messages
        {
            get { return this._message; }
            set { this._message = value; }
        }

        public Pets Pets
        {
            get { return this._pets; }
            set { this._pets = value; }
        }

        public Pets_storage Pets_Storage
        {
            get { return this._pets_storage; }
            set { this._pets_storage = value; }
        }

        public Rank_honor Rank_Honor
        {
            get { return this._rank_honor; }
            set { this._rank_honor = value; }
        }

        public Rank_job_activity Rank_Job_Activity
        {
            get { return this._rank_job_activity; }
            set { this._rank_job_activity = value; }
        }

        public Rank_job_donate Rank_Job_Donate
        {
            get { return this._rank_job_donate; }
            set { this._rank_job_donate = value; }
        }

        public Saved_skills Saved_Skills
        {
            get { return this._saved_skills; }
            set { this._saved_skills = value; }
        }

        public Storage_items Storage_items
        {
            get { return this._storage_items; }
            set { this._storage_items = value; }
        }

        public User Users
        {
            get { return this._users; }
            set { this._users = value; }
        }
//----------------------------------------------------------------------
        #endregion
        #region General Functions
//----------------------------------------------------------------------

        public void setConnection(MySqlConnection conn)
        {
            this.Connection = conn;
            this._char_items.setConnection(conn);
            this._character_jobs.setConnection(conn);
            this._character_quests.setConnection(conn);
            this._character_rev.setConnection(conn);
            this._character_tickets.setConnection(conn);
            this._characters.setConnection(conn);
            this._friends.setConnection(conn);
            this._friends_groups.setConnection(conn);
            this._guild.setConnection(conn);
            this._guild_members.setConnection(conn);
            this._guild_storage.setConnection(conn);
            this._guild_unions.setConnection(conn);
            this._guild_war.setConnection(conn);
            this._mastery.setConnection(conn);
            this._message.setConnection(conn);
            this._pets.setConnection(conn);
            this._pets_storage.setConnection(conn);
            this._rank_honor.setConnection(conn);
            this._rank_job_activity.setConnection(conn);
            this._rank_job_donate.setConnection(conn);
            this._saved_skills.setConnection(conn);
            this._storage_items.setConnection(conn);
            this._users.setConnection(conn);

        }

        public void loadFromDatabase()
        {
            this._char_items.refresh();
            this._character_jobs.refresh();
            this._character_quests.refresh();
            this._character_rev.refresh();
            this._character_tickets.refresh();
            this._characters.refresh();
            this._friends.refresh();
            this._friends_groups.refresh();
            this._guild.refresh();
            this._guild_members.refresh();
            this._guild_storage.refresh();
            this._guild_unions.refresh();
            this._guild_war.refresh();
            this._mastery.refresh();
            this._message.refresh();
            this._pets.refresh();
            this._pets_storage.refresh();
            this._rank_honor.refresh();
            this._rank_job_activity.refresh();
            this._rank_job_donate.refresh();
            this._saved_skills.refresh();
            this._storage_items.refresh();
            this._users.refresh();
        }
//----------------------------------------------------------------------
        #endregion

    }
}
